<template>
  <div class="tool">
    <div></div>
    <div>
      <span class="icon" aria-hidden="true" @click="minimizeWin">
        <svg class="icon">
          <use xlink:href="#icon-window-min_line"></use>
        </svg>
      </span>
      <span>
        <svg class="icon" aria-hidden="true" @click="maximizeWin">
          <use xlink:href="#icon-window-max_line"></use>
          <!--          <use xlink:href="#icon-window-window_line"></use>-->
        </svg>
      </span>
      <span>
        <svg class="icon" aria-hidden="true" @click="closeWin" @dblclick="exitWin">
          <use xlink:href="#icon-delete_line"></use>
        </svg>
      </span>
    </div>
  </div>
</template>

<script>
import {getIpcRenderer} from "@/util/utilString";

export default {
  name: 'Tool',
  description: {
    // 工具
  },
  setup() {
    const ipcRenderer = getIpcRenderer();

    function minimizeWin() {
      ipcRenderer.send('window-min') // 通知主进程我要进行窗口最小化操作
    }

    function maximizeWin() {
      ipcRenderer.send('window-max')
    }

    function closeWin() {
      ipcRenderer.send('window-close')
    }

    function exitWin() {
      ipcRenderer.send('window-exit')
    }

    return {
      minimizeWin,
      maximizeWin,
      closeWin,
      exitWin
    }
  }
}
</script>

<style scoped>

</style>
<style scoped lang="less">
@import url("@/assets/less/1.less");

.tool {
  /* 拖拽 */
  -webkit-app-region: drag;

  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-content: flex-end;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 0;
  width: 100%;
  height: 25px;
  background-color: @bc;

  & > div:nth-child(1) {

  }

  & > div:nth-child(2) {
    /* 禁止拖拽 */
    -webkit-app-region: no-drag;

    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: center;
    align-items: center;
    width: 150px;

    span {
      width: 50px;
      height: 100%;
      text-align: center;

      svg {
        .icon-min(@s:14px,@c:@fbc);
      }

      &:hover {
        background-color: @sc;

        svg {
          fill: @fcc;
        }
      }

      &:nth-child(1) svg {
        transform: translateY(-3px);
      }

      &:nth-child(2) {
        cursor: not-allowed;
        background-color: @bc;

        svg {
          fill: @fbc;
        }

        //pointer-events: none
      }
    }

  }
}
</style>
